package flink.function;

import org.apache.flink.api.common.functions.FilterFunction;

import com.alibaba.fastjson.JSONObject;

/**
 * @author ：Jason
 * @date ：Created in 2023/4/30 12:48 PM
 * @description：过滤 Jsonobject 含有指定 key 的数据
 * @modified By：
 * @version: 1.0
 */
public class FilterContainsKeyFunction<T> implements FilterFunction<T> {
    private final String key;

    public FilterContainsKeyFunction(String key) {
        this.key = key;
    }

    @Override
    public boolean filter(T value) throws Exception {
        return JSONObject.parseObject(String.valueOf(value)).containsKey(this.key);
    }
}
